package com.drophair.jspwork.Servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "LogoutServlet", value = "/LogoutServlet")
public class LogoutServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        super.doPost(request,response);
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");

        Cookie cookie=new Cookie("login_name",null);
        Cookie cookie1=new Cookie("uwho","-1");
        cookie.setMaxAge(0);
        cookie.setPath(request.getContextPath());
        response.addCookie(cookie);
        response.addCookie(cookie1);

        request.removeAttribute("goodid");
        request.removeAttribute("goodname");
        request.removeAttribute("good");
        response.sendRedirect("index.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        super.doGet(request,response);
    }
}
